#!/bin/bash

echo "Compiling the project..."

# 创建输出目录
mkdir -p bin

# 编译所有源文件，并包含lib目录中的库
javac -encoding UTF-8 -cp "lib/*" -d bin \
    src/Main/Main.java \
    src/LunaServer/config/*.java \
    src/LunaServer/core/*.java \
    src/LunaServer/email/*.java \
    src/LunaServer/gui/*.java \
    src/LunaServer/logging/*.java \
    src/LunaServer/routing/*.java \
    src/LunaServer/user/*.java \
    src/LunaServer/util/*.java

if [ $? -eq 0 ]; then
    echo "Compilation successful!"
    
    # 复制库文件到输出目录
    mkdir -p bin/lib
    cp lib/*.jar bin/lib/
    
    echo "Libraries copied to bin/lib"
    echo "Build completed successfully!"
else
    echo "Compilation failed!"
    read -p "Press enter to continue..."
    exit 1
fi